World = class('World'):include(Stateful)

function World:initialize(lat, long, ele, temp, ene, fri, res, feat, sea, seed)
	self.data = {}
	self.data.stats = {}
	self.data.stats.lat = lat
	self.data.stats.long = long
	self.data.stats.ele = ele
	self.data.stats.temp = temp
	self.data.stats.ene = ene
	self.data.stats.fri = fri
	self.data.stats.res = res
	self.data.stats.feat = feat
	self.data.stats.sea = sea
	self.data.grid = {}
	self.data.tile_width = 32
	self.data.tile_height = 32
	self.data.seed = seed or love.math.random(0, 1000000)
	
	for k, v in pairs(self.data.stats) do
		print(k .. " = " .. v)
	end
	
	if lat and long and ele and temp and ene and fri and res and feat and sea then
		local world_stats = love.thread.getChannel("world_stats")
		world_stats:push(self.data.stats)
		local world_seed = love.thread.getChannel("world_seed")
		if game.debug == true then		
			self.data.seed = 1		
		end
		world_seed:push(self.data.seed)
		self.gen_thread = love.thread.newThread('world_generator.lua')
		self.gen_thread:start()
	end
	

end

function World:add_tile(tile)
	--for k, v in pairs(tile) do
	--	print(k .. ":" .. v)
	--end
	if not self.data.grid[tile.z] then self.data.grid[tile.z] = {} end
	if not self.data.grid[tile.z][tile.y] then self.data.grid[tile.z][tile.y] = {} end
	if not self.data.grid[tile.z][tile.y][tile.x] then self.data.grid[tile.z][tile.y][tile.x] = {} end
	local this_tile = self.data.grid[tile.z][tile.y][tile.x]
	this_tile.type = tile.type
	this_tile.x = tile.x
	this_tile.y = tile.y
	this_tile.z = tile.z
	--print(tile.x .. " " .. tile.y .. " " .. tile.z)
end